﻿package graphic
{	
	import flash.display.MovieClip;
	import flash.events.Event;

	public class LinedCanvas extends MovieClip 
	{
		private var FBackgroundColor:uint;
		private var FLinesColor:uint;
		private var FDistance:int;
		
		public function LinedCanvas() 
		{
			FLinesColor = 0x333333;
			FBackgroundColor = 0x666666;
			FDistance = 26;
			ReDraw();
		}
		
		private function ReDraw(e:Event = null):void
		{
			trace(height);
			graphics.clear();
			graphics.beginFill(FBackgroundColor, 1);		
			graphics.drawRect(0, 0, width, height);
			graphics.beginFill(0x333333, 0.5);
			graphics.drawRect(0, height/2 - 7/2, width, 7);
			graphics.endFill();	
			graphics.beginFill(0x333333, 1);
			graphics.drawRect(0, height/2 - 1/2, width, 1);
			graphics.endFill();
			graphics.lineStyle(1, FLinesColor, 1);
			for(var i:int = FDistance; i < width; i += FDistance)
			{				
				graphics.moveTo(i, 0);
				graphics.lineTo(i, height);
			}
			graphics.endFill();	
		}		
		
		override public function set width(value:Number):void
		{	
			super.width = value;
			ReDraw();
		}
		
		override public function set height(value:Number):void
		{			
			super.height = value;
			ReDraw();
		}
		
		public function set BackgroundColor(AColor:uint)
		{
			BackgroundColor = AColor;
			ReDraw();
		}
		
		public function set LinesColor(AColor:uint)
		{
			FLinesColor = AColor;
			ReDraw();
		}
		
		public function set Distance(ADistance:int)
		{
			FDistance = ADistance;
			ReDraw();
		}
		
	}	
}
